

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>5.3. Common functions for coordinate reading — MDAnalysis.coordinates.core &mdash; MDAnalysis v0.7.5-devel documentation</title>
    <link rel="stylesheet" href="../../_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '0.7.5-devel',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within MDAnalysis v0.7.5-devel documentation"
          href="../../_static/opensearch.xml"/>
    <link rel="shortcut icon" href="../../_static/mdanalysis-logo.ico"/>
    <link rel="top" title="MDAnalysis v0.7.5-devel documentation" href="../../index.html" />
    <link rel="up" title="5. Coordinates modules" href="../coordinates_modules.html" />
    <link rel="next" title="5.4. CRD structure files in MDAnalysis — MDAnalysis.coordinates.CRD" href="CRD.html" />
    <link rel="prev" title="5.2. Base classes — MDAnalysis.coordinates.base" href="base.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="CRD.html" title="5.4. CRD structure files in MDAnalysis — MDAnalysis.coordinates.CRD"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="base.html" title="5.2. Base classes — MDAnalysis.coordinates.base"
             accesskey="P">previous</a> |</li>
        <li><a href="../../index.html">MDAnalysis v0.7.5-devel documentation</a> &raquo;</li>
          <li><a href="../coordinates_modules.html" accesskey="U">5. Coordinates modules</a> &raquo;</li> 
      </ul>
    </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/mdanalysis-logo-200x150.png" alt="Logo"/>
            </a></p>
  <h4>Previous topic</h4>
  <p class="topless"><a href="base.html"
                        title="previous chapter">5.2. Base classes &#8212; <tt class="docutils literal docutils literal"><span class="pre">MDAnalysis.coordinates.base</span></tt></a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="CRD.html"
                        title="next chapter">5.4. CRD structure files in MDAnalysis &#8212; <tt class="docutils literal docutils literal"><span class="pre">MDAnalysis.coordinates.CRD</span></tt></a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../../_sources/documentation_pages/coordinates/core.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <span class="target" id="module-MDAnalysis.coordinates.core"></span><div class="section" id="common-functions-for-coordinate-reading-mdanalysis-coordinates-core">
<h1>5.3. Common functions for coordinate reading &#8212; <a class="reference internal" href="#module-MDAnalysis.coordinates.core" title="MDAnalysis.coordinates.core"><tt class="xref py py-mod docutils literal"><span class="pre">MDAnalysis.coordinates.core</span></tt></a><a class="headerlink" href="#common-functions-for-coordinate-reading-mdanalysis-coordinates-core" title="Permalink to this headline">¶</a></h1>
<p>Important base classes are collected in <a class="reference internal" href="base.html#module-MDAnalysis.coordinates.base" title="MDAnalysis.coordinates.base"><tt class="xref py py-mod docutils literal"><span class="pre">MDAnalysis.coordinates.base</span></tt></a>.</p>
<dl class="function">
<dt id="MDAnalysis.coordinates.core.reader">
<tt class="descclassname">MDAnalysis.coordinates.core.</tt><tt class="descname">reader</tt><big>(</big><em>filename</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#MDAnalysis.coordinates.core.reader" title="Permalink to this definition">¶</a></dt>
<dd><p>Provide a trajectory reader instance for <em>filename</em>.</p>
<p>This function guesses the file format from the extension of <em>filename</em> and
it will throw a <tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt> if the extension is not recognized.</p>
<p>In most cases, no special keyword arguments are necessary. For some readers
(such as PDB) it might be useful to set the <em>permissive</em> = <tt class="xref docutils literal"><span class="pre">True</span></tt> flag to
select a simpler but faster reader.</p>
<p>All other keywords are passed on to the underlying Reader classes; see
their documentation for details.</p>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last">For trajectory formats: <tt class="xref py py-class docutils literal"><span class="pre">DCDReader</span></tt>,
<tt class="xref py py-class docutils literal"><span class="pre">XTCReader</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">TRRReader</span></tt>,
<tt class="xref py py-class docutils literal"><span class="pre">XYZReader</span></tt>.  For single frame formats:
<tt class="xref py py-class docutils literal"><span class="pre">CRDReader</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">PDBReader</span></tt> and
<tt class="xref py py-class docutils literal"><span class="pre">PrimitivePDBReader</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">GROReader</span></tt>,</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Arguments :</th><td class="field-body"><dl class="first last docutils">
<dt><em>filename</em></dt>
<dd><p class="first last">filename of the input trajectory or coordinate file</p>
</dd>
<dt><em>permissive</em></dt>
<dd><p class="first last">If set to <tt class="xref docutils literal"><span class="pre">True</span></tt>, a reader is selected that is more tolerant of the
input (currently only implemented for PDB). [<tt class="xref docutils literal"><span class="pre">False</span></tt>]</p>
</dd>
<dt><em>kwargs</em></dt>
<dd><p class="first last">Keyword arguments for the selected Reader class.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="MDAnalysis.coordinates.core.writer">
<tt class="descclassname">MDAnalysis.coordinates.core.</tt><tt class="descname">writer</tt><big>(</big><em>filename</em>, <em>numatoms=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#MDAnalysis.coordinates.core.writer" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize a trajectory writer instance for <em>filename</em>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Arguments :</th><td class="field-body"><dl class="first last docutils">
<dt><em>filename</em></dt>
<dd><p class="first last">Output filename of the trajectory; the extension determines the
format.</p>
</dd>
<dt><em>numatoms</em></dt>
<dd><p class="first last">The number of atoms in the output trajectory; can be ommitted
for single-frame writers.</p>
</dd>
<dt><em>kwargs</em></dt>
<dd><p class="first">Keyword arguments for the writer; all trajectory Writers accept
at least</p>
<blockquote>
<div><dl class="docutils">
<dt><em>start</em></dt>
<dd><p class="first last">starting time [0]</p>
</dd>
<dt><em>step</em></dt>
<dd><p class="first last">step size in frames [1]</p>
</dd>
<dt><em>delta</em></dt>
<dd><p class="first last">length of time between two frames, in ps [1.0]</p>
</dd>
</dl>
</div></blockquote>
<p>Some readers accept additional arguments, which need to be looked
up in the documentation of the reader.</p>
<div class="admonition-see-also last admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="DCD.html#MDAnalysis.coordinates.DCD.DCDWriter" title="MDAnalysis.coordinates.DCD.DCDWriter"><tt class="xref py py-class docutils literal"><span class="pre">DCDWriter</span></tt></a> for DCD
trajectories or <tt class="xref py py-class docutils literal"><span class="pre">XTCWriter</span></tt>
and <tt class="xref py py-class docutils literal"><span class="pre">TRRWriter</span></tt> for Gromacs.</p>
</div>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<p>Helper functions:</p>
<dl class="function">
<dt id="MDAnalysis.coordinates.core.get_reader_for">
<tt class="descclassname">MDAnalysis.coordinates.core.</tt><tt class="descname">get_reader_for</tt><big>(</big><em>filename</em>, <em>permissive=False</em>, <em>format=None</em><big>)</big><a class="headerlink" href="#MDAnalysis.coordinates.core.get_reader_for" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the appropriate trajectory reader class for <em>filename</em>.</p>
<p>Automatic detection is disabled when an explicit <em>format</em> is
provided.</p>
</dd></dl>

<dl class="function">
<dt id="MDAnalysis.coordinates.core.get_writer_for">
<tt class="descclassname">MDAnalysis.coordinates.core.</tt><tt class="descname">get_writer_for</tt><big>(</big><em>filename=None</em>, <em>format='DCD'</em><big>)</big><a class="headerlink" href="#MDAnalysis.coordinates.core.get_writer_for" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an appropriate trajectory or frame writer class for <em>filename</em>.</p>
<p>The format is determined by the <em>format</em> argument or the extension
of <em>filename</em>. The default is to return a dcd writer (<em>format</em> = &#8216;dcd&#8217;).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Arguments :</th><td class="field-body"><dl class="first last docutils">
<dt><em>filename</em></dt>
<dd><p class="first last">The filename for the trajectory is examined for its extension and
the Writer is chosen accordingly.</p>
</dd>
<dt><em>format</em></dt>
<dd><p class="first last">If no <em>filename</em> is supplied then the format can be explicitly set;
possible values are &#8220;DCD&#8221;, &#8220;XTC&#8221;, &#8220;TRR&#8221;; &#8220;PDB&#8221;, &#8220;CRD&#8221;, &#8220;GRO&#8221;.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="MDAnalysis.coordinates.core.guess_format">
<tt class="descclassname">MDAnalysis.coordinates.core.</tt><tt class="descname">guess_format</tt><big>(</big><em>filename</em>, <em>format=None</em><big>)</big><a class="headerlink" href="#MDAnalysis.coordinates.core.guess_format" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the type of coordinate file <em>filename</em>.</p>
<p>The current heuristic simply looks at the filename extension but
more complicated probes could be implemented here or in the
individual packages (e.g. as static methods).</p>
<p>If <em>format</em> is supplied then it overrides the auto detection.</p>
</dd></dl>

<dl class="function">
<dt id="MDAnalysis.coordinates.core.triclinic_box">
<tt class="descclassname">MDAnalysis.coordinates.core.</tt><tt class="descname">triclinic_box</tt><big>(</big><em>x</em>, <em>y</em>, <em>z</em><big>)</big><a class="headerlink" href="#MDAnalysis.coordinates.core.triclinic_box" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the three triclinic box vectors to [A,B,C,alpha,beta,gamma].</p>
<p>Angles are in degrees.</p>
<ul class="simple">
<li>alpha  = angle(y,z)</li>
<li>beta   = angle(x,z)</li>
<li>gamma  = angle(x,y)</li>
</ul>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last">Definition of angles: <a class="reference external" href="http://en.wikipedia.org/wiki/Lattice_constant">http://en.wikipedia.org/wiki/Lattice_constant</a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="MDAnalysis.coordinates.core.triclinic_vectors">
<tt class="descclassname">MDAnalysis.coordinates.core.</tt><tt class="descname">triclinic_vectors</tt><big>(</big><em>dimensions</em><big>)</big><a class="headerlink" href="#MDAnalysis.coordinates.core.triclinic_vectors" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert <cite>[A,B,C,alpha,beta,gamma]</cite> to a triclinic box representation.</p>
<p>Original <a class="reference external" href="http://www.mail-archive.com/gmx-users&#64;gromacs.org/msg28032.html">code by Tsjerk Wassenaar</a> posted on the Gromacs mailinglist</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Arguments :</th><td class="field-body"><dl class="first docutils">
<dt><em>dimensions</em></dt>
<dd><p class="first last">list of box lengths and angles (in degrees) such as
[A,B,C,alpha,beta,gamma]</p>
</dd>
</dl>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">numpy 3x3 array B, with B[0] = first box vector,
B[1] = second vector, B[2] third box vector.</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The first vector is always pointing along the X-axis
i.e. parallel to (1,0,0).</p>
</div>
</dd></dl>

<dl class="function">
<dt id="MDAnalysis.coordinates.core.box_volume">
<tt class="descclassname">MDAnalysis.coordinates.core.</tt><tt class="descname">box_volume</tt><big>(</big><em>dimensions</em><big>)</big><a class="headerlink" href="#MDAnalysis.coordinates.core.box_volume" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the volume of the unitcell described by <em>dimensions</em>.</p>
<p>The volume is computed as <cite>det(x1,x2,x2)</cite> where the xi are the
triclinic box vectors from <a class="reference internal" href="#MDAnalysis.coordinates.core.triclinic_vectors" title="MDAnalysis.coordinates.core.triclinic_vectors"><tt class="xref py py-func docutils literal"><span class="pre">triclinic_vectors()</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Arguments :</th><td class="field-body"><dl class="first docutils">
<dt><em>dimensions</em></dt>
<dd><p class="first last">list of box lengths and angles (in degrees) such as
[A,B,C,alpha,beta,gamma]</p>
</dd>
</dl>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">numpy 3x3 array B, with B[0] = first box vector,
B[1] = second vector, B[2] third box vector.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="CRD.html" title="5.4. CRD structure files in MDAnalysis — MDAnalysis.coordinates.CRD"
             >next</a> |</li>
        <li class="right" >
          <a href="base.html" title="5.2. Base classes — MDAnalysis.coordinates.base"
             >previous</a> |</li>
        <li><a href="../../index.html">MDAnalysis v0.7.5-devel documentation</a> &raquo;</li>
          <li><a href="../coordinates_modules.html" >5. Coordinates modules</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2005-2011, Naveen Michaud-Agrawal, Elizabeth J. Denning, Joshua Adelman,
    Christian Beckstein (logo), David Caplan, Jan Domański, Philip Fowler,
    Joseph Goose, Benjamin Hall, Danny Parton, Tyler Reddy, Paul Rigor,
    and Oliver Beckstein.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>
  </body>
</html>